﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SQLite;
using System.Windows.Forms;
using System.Data;


class ConexaoBancoDados
{
    private static SQLiteConnection instancia = null;

    public static SQLiteConnection ConexaoAtiva()
    {
        if (instancia == null)
        {
            String strCon = String.Format("Data Source={0}\\Banco.db3", Application.StartupPath);
            instancia = new SQLiteConnection(strCon);
            instancia.Open();

            try
            {
                DataTable dt = SQLUtils.GetDataTable(string.Format("SELECT * FROM {0}", "his_host"));
            }
            catch (Exception e)
            {
               // CREATE TABLE his_host ( name_host VARCHAR( 50 )  PRIMARY KEY  NOT NULL); 
                SQLiteCommand mycommand = new SQLiteCommand(ConexaoBancoDados.ConexaoAtiva());
                mycommand.CommandText = "CREATE TABLE his_host ( name_host VARCHAR( 50 )  PRIMARY KEY  NOT NULL)";
                mycommand.ExecuteNonQuery();
            }
        }
        return instancia;
    }



}
